let nums = [8,1,2,2,3]
var smallerNumbersThanCurrent = function(nums) {
    let arr = new Array(101).fill(0)
    let result = []
    for(let i=0;i<nums.length;i++){
        arr[nums[i]] +=1;
    }
    for(let i=1;i<arr.length;i++){
        arr[i] += arr[i-1]
    }
    for(let i=0;i<nums.length;i++){
        if(nums){
            result.push(arr[nums[i]-1])
        }else{
            result.push(0)
        }
        
    }
    return result
}
console.log(smallerNumbersThanCurrent(nums));
